eric6/Plugins/VcsPlugins/vcsGit/GitPushDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
55 55
56 for localBranch in self.__localBranches: 56 for localBranch in self.__localBranches:
57 itm = QTreeWidgetItem(self.branchesTree, ["", localBranch, "", ""]) 57 itm = QTreeWidgetItem(self.branchesTree, ["", localBranch, "", ""])
58 combo = QComboBox() 58 combo = QComboBox()
59 combo.setEditable(True) 59 combo.setEditable(True)
60 combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) 60 combo.setSizeAdjustPolicy(
61 QComboBox.SizeAdjustPolicy.AdjustToContents)
61 self.branchesTree.setItemWidget( 62 self.branchesTree.setItemWidget(
62 itm, GitPushDialog.RemoteBranchColumn, combo) 63 itm, GitPushDialog.RemoteBranchColumn, combo)
63 64
64 self.__resizeColumns() 65 self.__resizeColumns()
65 66
66 self.branchesTree.header().setSortIndicator( 67 self.branchesTree.header().setSortIndicator(
67 GitPushDialog.LocalBranchColumn, Qt.AscendingOrder) 68 GitPushDialog.LocalBranchColumn, Qt.SortOrder.AscendingOrder)
68 69
69 self.forceWarningLabel.setVisible(False) 70 self.forceWarningLabel.setVisible(False)
70 71
71 index = self.remotesComboBox.findText("origin") 72 index = self.remotesComboBox.findText("origin")
72 if index == -1: 73 if index == -1:
97 combo.clear() 98 combo.clear()
98 combo.addItems([""] + sorted(self.__remotes[txt])) 99 combo.addItems([""] + sorted(self.__remotes[txt]))
99 index = combo.findText(localBranch) 100 index = combo.findText(localBranch)
100 if index != -1: 101 if index != -1:
101 combo.setCurrentIndex(index) 102 combo.setCurrentIndex(index)
102 itm.setCheckState(GitPushDialog.PushColumn, Qt.Checked) 103 itm.setCheckState(GitPushDialog.PushColumn,
104 Qt.CheckState.Checked)
103 else: 105 else:
104 itm.setCheckState(GitPushDialog.PushColumn, Qt.Unchecked) 106 itm.setCheckState(GitPushDialog.PushColumn,
105 itm.setCheckState(GitPushDialog.ForceColumn, Qt.Unchecked) 107 Qt.CheckState.Unchecked)
108 itm.setCheckState(GitPushDialog.ForceColumn,
109 Qt.CheckState.Unchecked)
106 110
107 self.__resizeColumns() 111 self.__resizeColumns()
108 112
109 @pyqtSlot(QTreeWidgetItem, int) 113 @pyqtSlot(QTreeWidgetItem, int)
110 def on_branchesTree_itemChanged(self, item, column): 114 def on_branchesTree_itemChanged(self, item, column):
115 @param column changed column (integer) 119 @param column changed column (integer)
116 """ 120 """
117 if column == GitPushDialog.PushColumn: 121 if column == GitPushDialog.PushColumn:
118 # step 1: set the item's remote branch, if it is empty 122 # step 1: set the item's remote branch, if it is empty
119 if ( 123 if (
120 item.checkState(GitPushDialog.PushColumn) == Qt.Checked and 124 item.checkState(GitPushDialog.PushColumn) ==
125 Qt.CheckState.Checked and
121 (self.branchesTree.itemWidget( 126 (self.branchesTree.itemWidget(
122 item, 127 item,
123 GitPushDialog.RemoteBranchColumn 128 GitPushDialog.RemoteBranchColumn
124 ).currentText() == "") 129 ).currentText() == "")
125 ): 130 ):
129 134
130 # step 2: count checked items 135 # step 2: count checked items
131 checkedItemsCount = 0 136 checkedItemsCount = 0
132 for row in range(self.branchesTree.topLevelItemCount()): 137 for row in range(self.branchesTree.topLevelItemCount()):
133 itm = self.branchesTree.topLevelItem(row) 138 itm = self.branchesTree.topLevelItem(row)
134 if itm.checkState(GitPushDialog.PushColumn) == Qt.Checked: 139 if (
140 itm.checkState(GitPushDialog.PushColumn) ==
141 Qt.CheckState.Checked
142 ):
135 checkedItemsCount += 1 143 checkedItemsCount += 1
136 if checkedItemsCount == len(self.__localBranches): 144 if checkedItemsCount == len(self.__localBranches):
137 self.selectAllCheckBox.setCheckState(Qt.Checked) 145 self.selectAllCheckBox.setCheckState(Qt.CheckState.Checked)
138 elif checkedItemsCount == 0: 146 elif checkedItemsCount == 0:
139 self.selectAllCheckBox.setCheckState(Qt.Unchecked) 147 self.selectAllCheckBox.setCheckState(Qt.CheckState.Unchecked)
140 else: 148 else:
141 self.selectAllCheckBox.setCheckState(Qt.PartiallyChecked) 149 self.selectAllCheckBox.setCheckState(
150 Qt.CheckState.PartiallyChecked)
142 151
143 elif column == GitPushDialog.ForceColumn: 152 elif column == GitPushDialog.ForceColumn:
144 forceItemsCount = 0 153 forceItemsCount = 0
145 for row in range(self.branchesTree.topLevelItemCount()): 154 for row in range(self.branchesTree.topLevelItemCount()):
146 itm = self.branchesTree.topLevelItem(row) 155 itm = self.branchesTree.topLevelItem(row)
147 if itm.checkState(GitPushDialog.ForceColumn) == Qt.Checked: 156 if (
157 itm.checkState(GitPushDialog.ForceColumn) ==
158 Qt.CheckState.Checked
159 ):
148 forceItemsCount += 1 160 forceItemsCount += 1
149 self.forceWarningLabel.setVisible(forceItemsCount > 0) 161 self.forceWarningLabel.setVisible(forceItemsCount > 0)
150 162
151 @pyqtSlot(int) 163 @pyqtSlot(int)
152 def on_selectAllCheckBox_stateChanged(self, state): 164 def on_selectAllCheckBox_stateChanged(self, state):
153 """ 165 """
154 Private slot to select/deselect all branch items. 166 Private slot to select/deselect all branch items.
155 167
156 @param state check state of the check box (Qt.CheckState) 168 @param state check state of the check box (Qt.CheckState)
157 """ 169 """
158 if state != Qt.PartiallyChecked: 170 if state != Qt.CheckState.PartiallyChecked:
159 for row in range(self.branchesTree.topLevelItemCount()): 171 for row in range(self.branchesTree.topLevelItemCount()):
160 itm = self.branchesTree.topLevelItem(row) 172 itm = self.branchesTree.topLevelItem(row)
161 if itm.checkState(GitPushDialog.PushColumn) != state: 173 if itm.checkState(GitPushDialog.PushColumn) != state:
162 itm.setCheckState(GitPushDialog.PushColumn, state) 174 itm.setCheckState(GitPushDialog.PushColumn, state)
163 175
171 @rtype tuple of (str, list of str, bool, bool, str) 183 @rtype tuple of (str, list of str, bool, bool, str)
172 """ 184 """
173 refspecs = [] 185 refspecs = []
174 for row in range(self.branchesTree.topLevelItemCount()): 186 for row in range(self.branchesTree.topLevelItemCount()):
175 itm = self.branchesTree.topLevelItem(row) 187 itm = self.branchesTree.topLevelItem(row)
176 force = itm.checkState(GitPushDialog.ForceColumn) == Qt.Checked 188 force = (
177 if itm.checkState(GitPushDialog.PushColumn) == Qt.Checked: 189 itm.checkState(GitPushDialog.ForceColumn) ==
190 Qt.CheckState.Checked
191 )
192 if (
193 itm.checkState(GitPushDialog.PushColumn) ==
194 Qt.CheckState.Checked
195 ):
178 localBranch = itm.text(GitPushDialog.LocalBranchColumn) 196 localBranch = itm.text(GitPushDialog.LocalBranchColumn)
179 remoteBranch = self.branchesTree.itemWidget( 197 remoteBranch = self.branchesTree.itemWidget(
180 itm, GitPushDialog.RemoteBranchColumn).currentText() 198 itm, GitPushDialog.RemoteBranchColumn).currentText()
181 refspecs.append("{0}{1}:{2}".format( 199 refspecs.append("{0}{1}:{2}".format(
182 "+" if force else "", localBranch, remoteBranch)) 200 "+" if force else "", localBranch, remoteBranch))

eric ide

mercurial