21
21
QAbstractItemView , QProgressDialog , QTableView ,
22
22
QPushButton , QLabel , QTabWidget , QToolTip ,
23
23
QDesktopServices )
24
- from winpython .qt .QtCore import (Qt , QAbstractTableModel , QModelIndex , SIGNAL ,
24
+ from winpython .qt .QtCore import (Qt , QAbstractTableModel , QModelIndex , Signal ,
25
25
QThread , QTimer , QUrl )
26
26
from winpython .qt .compat import (to_qvariant , getopenfilenames ,
27
27
getexistingdirectory )
41
41
42
42
43
43
class PackagesModel (QAbstractTableModel ):
44
+ # Signals after PyQt4 old SIGNAL removal
45
+ dataChanged = Signal (QModelIndex , QModelIndex )
46
+
44
47
def __init__ (self ):
45
48
QAbstractTableModel .__init__ (self )
46
49
self .packages = []
@@ -127,8 +130,9 @@ def setData(self, index, value, role=Qt.EditRole):
127
130
self .checked .remove (package )
128
131
else :
129
132
self .checked .add (package )
130
- self .emit (SIGNAL ("dataChanged(QModelIndex,QModelIndex)" ),
131
- index , index )
133
+ # PyQt4 old SIGNAL: self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
134
+ # PyQt4 old SIGNAL: index, index)
135
+ self .dataChanged .emit (index , index )
132
136
return True
133
137
return False
134
138
@@ -141,6 +145,9 @@ def setData(self, index, value, role=Qt.EditRole):
141
145
142
146
143
147
class PackagesTable (QTableView ):
148
+ # Signals after PyQt4 old SIGNAL removal, to be emitted after package_added event
149
+ package_added = Signal ()
150
+
144
151
def __init__ (self , parent , process , winname ):
145
152
QTableView .__init__ (self , parent )
146
153
assert process in ('install' , 'uninstall' )
@@ -185,7 +192,8 @@ def add_packages(self, fnames):
185
192
notcompatible .append (bname )
186
193
except NotImplementedError :
187
194
notsupported .append (bname )
188
- self .emit (SIGNAL ('package_added()' ))
195
+ # PyQt4 old SIGNAL: self.emit(SIGNAL('package_added()'))
196
+ self .package_added .emit ()
189
197
if notsupported :
190
198
QMessageBox .warning (self , "Warning" ,
191
199
"The following packages filenaming are <b>not "
@@ -272,6 +280,9 @@ class DistributionSelector(QWidget):
272
280
"""Python distribution selector widget"""
273
281
TITLE = 'Select a Python distribution path'
274
282
283
+ # Signals after PyQt4 old SIGNAL removal
284
+ selected_distribution = Signal (str )
285
+
275
286
def __init__ (self , parent ):
276
287
super (DistributionSelector , self ).__init__ (parent )
277
288
self .browse_btn = None
@@ -292,8 +303,9 @@ def setup_widget(self):
292
303
# self.line_edit.setDisabled(True)
293
304
self .browse_btn = QPushButton (get_std_icon ('DirOpenIcon' ), "" , self )
294
305
self .browse_btn .setToolTip (self .TITLE )
295
- self .connect (self .browse_btn , SIGNAL ("clicked()" ),
296
- self .select_directory )
306
+ # PyQt4 old SIGNAL:self.connect(self.browse_btn, SIGNAL("clicked()"),
307
+ # PyQt4 old SIGNAL: self.select_directory)
308
+ self .browse_btn .clicked .connect (self .select_directory )
297
309
layout = QHBoxLayout ()
298
310
layout .addWidget (self .label )
299
311
layout .addWidget (self .line_edit )
@@ -318,7 +330,8 @@ def select_directory(self):
318
330
continue
319
331
directory = osp .abspath (osp .normpath (directory ))
320
332
self .set_distribution (directory )
321
- self .emit (SIGNAL ('selected_distribution(QString)' ), directory )
333
+ # PyQt4 old SIGNAL: self.emit(SIGNAL('selected_distribution(QString)'), directory)
334
+ self .selected_distribution .emit (directory )
322
335
break
323
336
324
337
@@ -338,7 +351,7 @@ def run(self):
338
351
or locale .getpreferredencoding ()
339
352
try :
340
353
error_str = error_str .decode (fs_encoding )
341
- except (UnicodeError , TypeError ):
354
+ except (UnicodeError , TypeError , AttributeError ):
342
355
pass
343
356
self .error = error_str
344
357
@@ -394,25 +407,32 @@ def setup_window(self):
394
407
self .setWindowIcon (get_icon ('winpython.svg' ))
395
408
396
409
self .selector = DistributionSelector (self )
397
- self .connect (self .selector , SIGNAL ('selected_distribution(QString)' ),
398
- self .distribution_changed )
410
+ # PyQt4 old SIGNAL: self.connect(self.selector, SIGNAL('selected_distribution(QString)'),
411
+ # PyQt4 old SIGNAL: self.distribution_changed)
412
+ self .selector .selected_distribution .connect (self .distribution_changed )
399
413
400
414
self .table = PackagesTable (self , 'install' , self .NAME )
401
- self .connect (self .table , SIGNAL ('package_added()' ),
402
- self .refresh_install_button )
403
- self .connect (self .table , SIGNAL ("clicked(QModelIndex)" ),
404
- lambda index : self .refresh_install_button ())
415
+ # PyQt4 old SIGNAL:self.connect(self.table, SIGNAL('package_added()'),
416
+ # PyQt4 old SIGNAL: self.refresh_install_button)
417
+ self .table .package_added .connect (self .refresh_install_button )
418
+
419
+ # PyQt4 old SIGNAL: self.connect(self.table, SIGNAL("clicked(QModelIndex)"),
420
+ # PyQt4 old SIGNAL: lambda index: self.refresh_install_button())
421
+ self .table .clicked .connect (lambda index : self .refresh_install_button ())
405
422
406
423
self .untable = PackagesTable (self , 'uninstall' , self .NAME )
407
- self .connect (self .untable , SIGNAL ("clicked(QModelIndex)" ),
408
- lambda index : self .refresh_uninstall_button ())
424
+ # PyQt4 old SIGNAL:self.connect(self.untable, SIGNAL("clicked(QModelIndex)"),
425
+ # PyQt4 old SIGNAL: lambda index: self.refresh_uninstall_button())
426
+ self .untable .clicked .connect (lambda index : self .refresh_uninstall_button ())
409
427
410
428
self .selector .set_distribution (sys .prefix )
411
429
self .distribution_changed (sys .prefix )
412
430
413
431
self .tabwidget = QTabWidget ()
414
- self .connect (self .tabwidget , SIGNAL ('currentChanged(int)' ),
415
- self .current_tab_changed )
432
+ # PyQt4 old SIGNAL:self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
433
+ # PyQt4 old SIGNAL: self.current_tab_changed)
434
+ self .tabwidget .currentChanged .connect (self .current_tab_changed )
435
+
416
436
btn_layout = self ._add_table (self .table , "Install/upgrade packages" ,
417
437
get_std_icon ("ArrowDown" ))
418
438
unbtn_layout = self ._add_table (self .untable , "Uninstall packages" ,
0 commit comments