@@ -262,15 +262,27 @@ def __init__(self, parent, fl):
262
262
self .connect (self .buttonAddRep , SIGNAL ("clicked()" ), self .addRepository )
263
263
self .connect (self .buttonEditRep , SIGNAL ("clicked()" ), self .editRepository )
264
264
self .connect (self .buttonDeleteRep , SIGNAL ("clicked()" ), self .deleteRepository )
265
- # checkingOnStart checkbox
266
- self .connect (self .checkUpdates , SIGNAL ("stateChanged (int)" ), self .ChangeCheckingPolicy )
267
- if repositories .checkingOnStart ():
268
- self .checkUpdates .setCheckState (Qt .Checked )
269
- else :
270
- self .checkUpdates .setCheckState (Qt .Unchecked )
271
265
self .buttonEditRep .setEnabled (False )
272
266
self .buttonDeleteRep .setEnabled (False )
273
-
267
+ # configuration widgets
268
+ self .connect (self .checkUpdates , SIGNAL ("toggled (bool)" ), self .changeCheckingPolicy )
269
+ self .connect (self .comboInterval , SIGNAL ("currentIndexChanged (int)" ), self .changeCheckingInterval )
270
+ self .connect (self .radioPluginType0 , SIGNAL ("toggled (bool)" ), self .changePluginPolicy )
271
+ self .connect (self .radioPluginType1 , SIGNAL ("toggled (bool)" ), self .changePluginPolicy )
272
+ self .connect (self .radioPluginType2 , SIGNAL ("toggled (bool)" ), self .changePluginPolicy )
273
+ if repositories .checkingOnStart ():
274
+ self .checkUpdates .setChecked (Qt .Checked )
275
+ else :
276
+ self .checkUpdates .setChecked (Qt .Unchecked )
277
+ interval = repositories .checkingOnStartInterval ()
278
+ intervals = [0 ,1 ,3 ,7 ,14 ,30 ] # days
279
+ if intervals .count (interval ):
280
+ index = intervals .index (interval )
281
+ else :
282
+ index = 1
283
+ if QGIS_VER [0 ] == "0" :
284
+ self .label_2 .setText ("<b>Note: This functionality requires QGIS 1.0</b>" )
285
+ self .comboInterval .setCurrentIndex (index )
274
286
self .populateMostWidgets ()
275
287
276
288
@@ -328,13 +340,32 @@ def populateMostWidgets(self):
328
340
for i in [0 ,1 ,2 ]:
329
341
self .treeRepositories .resizeColumnToContents (i )
330
342
self .comboFilter1 .addItem (self .tr ("orphans" ))
331
- # filling the status filter comboBox
343
+ # fill the status filter comboBox
332
344
self .comboFilter2 .clear ()
333
345
self .comboFilter2 .addItem (self .tr ("any status" ))
334
346
self .comboFilter2 .addItem (self .tr ("not installed" , "plural" ))
335
347
self .comboFilter2 .addItem (self .tr ("installed" , "plural" ))
336
348
if plugins .isThereAnythingNew ():
337
349
self .comboFilter2 .addItem (self .tr ("upgradeable and news" ))
350
+ #set configuration widgets (dependent on the repository list)
351
+ if len (repositories .all ()) == 1 or QGIS_VER [0 ] == "0" :
352
+ self .radioPluginType0 .setEnabled (False )
353
+ self .radioPluginType1 .setEnabled (False )
354
+ self .radioPluginType2 .setEnabled (False )
355
+ else :
356
+ self .radioPluginType0 .setEnabled (True )
357
+ self .radioPluginType1 .setEnabled (True )
358
+ self .radioPluginType2 .setEnabled (True )
359
+ settings = QSettings ()
360
+ (i , ok ) = settings .value (settingsGroup + "/allowedPluginType" , QVariant (2 )).toInt ()
361
+ if QGIS_VER [0 ] == "0" :
362
+ self .radioPluginType1 .setChecked (Qt .Checked )
363
+ elif i == 1 or len (repositories .all ()) == 1 :
364
+ self .radioPluginType0 .setChecked (Qt .Checked )
365
+ elif i == 3 :
366
+ self .radioPluginType2 .setChecked (Qt .Checked )
367
+ else :
368
+ self .radioPluginType1 .setChecked (Qt .Checked )
338
369
339
370
340
371
# ----------------------------------------- #
@@ -358,14 +389,17 @@ def filterCheck(self,plugin):
358
389
return False
359
390
if self .comboFilter2 .currentIndex () == 3 and not plugin ["status" ] in ["upgradeable" ,"new" ]:
360
391
return False
392
+ if self .radioPluginType0 .isChecked () and plugin ["repository" ] != officialRepo [0 ] and plugin ["status" ] in ["not installed" ,"new" ]:
393
+ return False
394
+ if self .radioPluginType1 .isChecked () and plugin ["experimental" ] and plugin ["status" ] in ["not installed" ,"new" ]:
395
+ return False
361
396
if self .lineFilter .text () == "" :
362
397
return True
363
398
else :
364
399
for i in ["name" ,"version_inst" ,"version_avail" ,"desc_repo" ,"desc_local" ,"author" ,"status" ,"repository" ]:
365
400
item = QString (plugin [i ]) #.toUpper()
366
401
if item != None :
367
402
if item .contains (self .lineFilter .text (), Qt .CaseInsensitive ):
368
- #if item.find(self.lineFilter.text().toUpper()) > -1:
369
403
return True
370
404
return False
371
405
@@ -658,17 +692,41 @@ def repositoryTreeClicked(self):
658
692
659
693
660
694
# ----------------------------------------- #
661
- def ChangeCheckingPolicy (self ,policy ):
662
- if policy == Qt .Checked :
695
+ def changeCheckingPolicy (self ,policy ):
696
+ """ the Checking On Start checkbox has been clicked """
697
+ if policy :
663
698
repositories .setCheckingOnStart (True )
664
699
else :
665
700
repositories .setCheckingOnStart (False )
666
701
667
702
703
+ # ----------------------------------------- #
704
+ def changeCheckingInterval (self ,interval ):
705
+ """ the Checking on start interval combobox has been clicked """
706
+ intervals = [0 ,1 ,3 ,7 ,14 ,30 ]
707
+ repositories .setCheckingOnStartInterval (intervals [interval ])
708
+
709
+
710
+ # ----------------------------------------- #
711
+ def changePluginPolicy (self , state ):
712
+ """ one of the plugin type radiobuttons has been clicked """
713
+ if not state : # radio button released
714
+ return
715
+ if self .radioPluginType0 .isChecked ():
716
+ i = 1
717
+ elif self .radioPluginType1 .isChecked ():
718
+ i = 2
719
+ else :
720
+ i = 3
721
+ settings = QSettings ()
722
+ settings .setValue (settingsGroup + "/allowedPluginType" , QVariant (i ))
723
+ self .populatePluginTree ()
724
+
725
+
668
726
# ----------------------------------------- #
669
727
def addKnownRepositories (self ):
670
728
""" update list of known repositories - in the future it will be replaced with an online fetching """
671
- message = self .tr ("You are going to add some plugin repositories neither authorized nor supported by the Quantum GIS team, however provided by folks associated with us . Plugin authors generally make efforts to make their works useful and safe, but we can't assume any responsibility for them. FEEL WARNED! " )
729
+ message = self .tr ("You are about to add several plugin repositories that are neither authorized nor supported by the Quantum GIS team. Plugin authors generally make efforts to ensure that their work is useful and safe, however, we can assume no responsibility for them." )
672
730
if QMessageBox .question (self , self .tr ("QGIS Python Plugin Installer" ), message , QMessageBox .Ok , QMessageBox .Abort ) == QMessageBox .Ok :
673
731
repositories .addKnownRepos ()
674
732
# refresh lists and populate widgets
@@ -687,13 +745,13 @@ def addRepository(self):
687
745
if not dlg .exec_ ():
688
746
return
689
747
for i in repositories .all ().values ():
690
- if dlg .editURL .text () == i ["url" ]:
748
+ if dlg .editURL .text (). trimmed () == i ["url" ]:
691
749
QMessageBox .warning (self , self .tr ("QGIS Python Plugin Installer" ), self .tr ("Unable to add another repository with the same URL!" ))
692
750
return
693
751
settings = QSettings ()
694
752
settings .beginGroup (self .reposGroup )
695
753
reposName = dlg .editName .text ()
696
- reposURL = dlg .editURL .text ()
754
+ reposURL = dlg .editURL .text (). trimmed ()
697
755
if repositories .all ().has_key (reposName ):
698
756
reposName = reposName + "(2)"
699
757
# add to settings
@@ -729,7 +787,7 @@ def editRepository(self):
729
787
if not dlg .exec_ ():
730
788
return # nothing to do if cancelled
731
789
for i in repositories .all ().values ():
732
- if dlg .editURL .text () == i ["url" ] and dlg .editURL .text () != repositories .all ()[reposName ]["url" ]:
790
+ if dlg .editURL .text (). trimmed () == i ["url" ] and dlg .editURL .text (). trimmed () != repositories .all ()[reposName ]["url" ]:
733
791
QMessageBox .warning (self , self .tr ("QGIS Python Plugin Installer" ), self .tr ("Unable to add another repository with the same URL!" ))
734
792
return
735
793
# delete old repo from QSettings and create new one
@@ -739,9 +797,9 @@ def editRepository(self):
739
797
newName = dlg .editName .text ()
740
798
if repositories .all ().has_key (newName ) and newName != reposName :
741
799
newName = newName + "(2)"
742
- settings .setValue (newName + "/url" , QVariant (dlg .editURL .text ()))
800
+ settings .setValue (newName + "/url" , QVariant (dlg .editURL .text (). trimmed () ))
743
801
settings .setValue (newName + "/enabled" , QVariant (bool (dlg .checkBoxEnabled .checkState ())))
744
- if dlg .editURL .text () == repositories .all ()[reposName ]["url" ] and dlg .checkBoxEnabled .checkState () == checkState [repositories .all ()[reposName ]["enabled" ]]:
802
+ if dlg .editURL .text (). trimmed () == repositories .all ()[reposName ]["url" ] and dlg .checkBoxEnabled .checkState () == checkState [repositories .all ()[reposName ]["enabled" ]]:
745
803
repositories .rename (reposName , newName )
746
804
self .populateMostWidgets ()
747
805
return # nothing else to do if only repository name was changed
0 commit comments