Skip to content

Commit 300e864

Browse files
committed
Merge pull request #892 from alexbruy/deprecated_plugins
Deprecated plugins support for plugin manager
2 parents 9ce316d + 6d5df7c commit 300e864

File tree

7 files changed

+457
-326
lines changed

7 files changed

+457
-326
lines changed

images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
<file>themes/default/pie-chart.png</file>
370370
<file>themes/default/plugin.png</file>
371371
<file>themes/default/pluginExperimental.png</file>
372+
<file>themes/default/pluginDeprecated.png</file>
372373
<file>themes/default/propertyicons/action.svg</file>
373374
<file>themes/default/propertyicons/attributes.png</file>
374375
<file>themes/default/propertyicons/colormap.png</file>
3.15 KB
Loading

python/pyplugin_installer/installer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def exportPluginsToManager(self):
208208
"error" : plugin["error"],
209209
"error_details" : plugin["error_details"],
210210
"experimental" : plugin["experimental"] and "true" or "false",
211+
"deprecated" : plugin["deprecated"] and "true" or "false",
211212
"version_available" : plugin["version_available"],
212213
"zip_repository" : plugin["zip_repository"],
213214
"download_url" : plugin["download_url"],

python/pyplugin_installer/installer_data.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"error" unicode, # NULL | broken | incompatible | dependent
7272
"error_details" unicode, # error description
7373
"experimental" boolean, # true if experimental, false if stable
74+
"deprecated" boolean, # true if deprected, false if actual
7475
"version_available" unicode, # available version
7576
"zip_repository" unicode, # the remote repository id
7677
"download_url" unicode, # url for downloading the plugin
@@ -403,6 +404,9 @@ def xmlDownloaded(self):
403404
experimental = False
404405
if pluginNodes.item(i).firstChildElement("experimental").text().strip().upper() in ["TRUE","YES"]:
405406
experimental = True
407+
deprecated = False
408+
if pluginNodes.item(i).firstChildElement("deprecated").text().strip().upper() in ["TRUE","YES"]:
409+
deprecated = True
406410
icon = pluginNodes.item(i).firstChildElement("icon").text().strip()
407411
if icon and not icon.startswith("http"):
408412
icon = "http://%s/%s" % ( QUrl(self.mRepositories[reposName]["url"]).host() , icon )
@@ -427,6 +431,7 @@ def xmlDownloaded(self):
427431
"rating_votes" : pluginNodes.item(i).firstChildElement("rating_votes").text().strip(),
428432
"icon" : icon,
429433
"experimental" : experimental,
434+
"deprecated" : deprecated,
430435
"filename" : fileName,
431436
"installed" : False,
432437
"available" : True,
@@ -645,6 +650,7 @@ def pluginMetadata(fct):
645650
"library" : path,
646651
"pythonic" : True,
647652
"experimental" : pluginMetadata("experimental").strip().upper() in ["TRUE","YES"],
653+
"deprecated" : pluginMetadata("deprecated").strip().upper() in ["TRUE","YES"],
648654
"version_available" : "",
649655
"zip_repository" : "",
650656
"download_url" : path, # warning: local path as url!
@@ -707,12 +713,14 @@ def rebuild(self):
707713
self.mPlugins[i] = self.localCache[i].copy()
708714
settings = QSettings()
709715
allowExperimental = settings.value(settingsGroup+"/allowExperimental", False, type=bool)
716+
allowDeprecated = settings.value(settingsGroup+"/allowDeprecated", False, type=bool)
710717
for i in self.repoCache.values():
711718
for j in i:
712719
plugin=j.copy() # do not update repoCache elements!
713720
key = plugin["id"]
714721
# check if the plugin is allowed and if there isn't any better one added already.
715722
if (allowExperimental or not plugin["experimental"]) \
723+
and (allowDeprecated or not plugin["deprecated"]) \
716724
and not (self.mPlugins.has_key(key) and self.mPlugins[key]["version_available"] and compareVersions(self.mPlugins[key]["version_available"], plugin["version_available"]) < 2):
717725
# The mPlugins dict contains now locally installed plugins.
718726
# Now, add the available one if not present yet or update it if present already.
@@ -729,7 +737,7 @@ def rebuild(self):
729737
self.mPlugins[key][attrib] = plugin[attrib]
730738
# other remote metadata is preffered:
731739
for attrib in ["name", "description", "about", "category", "tags", "changelog", "author_name", "author_email", "homepage",
732-
"tracker", "code_repository", "experimental", "version_available", "zip_repository",
740+
"tracker", "code_repository", "experimental", "deprecated", "version_available", "zip_repository",
733741
"download_url", "filename", "downloads", "average_vote", "rating_votes"]:
734742
if ( not attrib in translatableAttributes ) or ( attrib == "name" ): # include name!
735743
if plugin[attrib]:

src/app/pluginmanager/qgspluginmanager.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils* pythonUtils )
187187
ckbExperimental->setChecked( true );
188188
}
189189

190+
if ( settings.value( settingsGroup + "/allowDeprecated", false ).toBool() )
191+
{
192+
ckbDeprecated->setChecked( true );
193+
}
194+
195+
190196
int interval = settings.value( settingsGroup + "/checkOnStartInterval", "" ).toInt( );
191197
int indx = mCheckingOnStartIntervals.indexOf( interval ); // if none found, just use -1 index.
192198
comboInterval->setCurrentIndex( indx );
@@ -659,6 +665,14 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
659665
" </td></tr>"
660666
"</table>" ).arg( tr( "This plugin is experimental" ) );
661667
};
668+
if ( metadata->value( "deprecated" ) == "true" )
669+
{
670+
html += QString( "<table bgcolor=\"#EEBBCC\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
671+
" <tr><td width=\"100%\" style=\"color:#660000\">"
672+
" <img src=\":/images/themes/default/pluginDeprecated.png\" width=\"32\"><b>%1</b>"
673+
" </td></tr>"
674+
"</table>" ).arg( tr( "This plugin is deprecated" ) );
675+
};
662676
// if ( metadata->value( "status" ) == t.b.d. )
663677
// {
664678
// html += QString( "<table bgcolor=\"#CCCCFF\" cellspacing=\"2\" cellpadding=\"6\" width=\"100%\">"
@@ -1228,6 +1242,15 @@ void QgsPluginManager::on_ckbExperimental_toggled( bool state )
12281242
QgsPythonRunner::run( "pyplugin_installer.instance().exportPluginsToManager()" );
12291243
}
12301244

1245+
void QgsPluginManager::on_ckbDeprecated_toggled( bool state )
1246+
{
1247+
QString settingsGroup;
1248+
QgsPythonRunner::eval( "pyplugin_installer.instance().exportSettingsGroup()", settingsGroup );
1249+
QSettings settings;
1250+
settings.setValue( settingsGroup + "/allowDeprecated", QVariant( state ) );
1251+
QgsPythonRunner::run( "pyplugin_installer.installer_data.plugins.rebuild()" );
1252+
QgsPythonRunner::run( "pyplugin_installer.instance().exportPluginsToManager()" );
1253+
}
12311254

12321255

12331256
// PRIVATE METHODS ///////////////////////////////////////////////////////////////////

src/app/pluginmanager/qgspluginmanager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
153153
//! Reload plugin metadata registry after allowing/disallowing experimental plugins
154154
void on_ckbExperimental_toggled( bool state );
155155

156+
//! Reload plugin metadata registry after allowing/disallowing deprecated plugins
157+
void on_ckbDeprecated_toggled( bool state );
158+
156159
//! Open help browser
157160
void on_buttonBox_helpRequested( ) { QgsContextHelp::run( metaObject()->className() ); }
158161

0 commit comments

Comments
 (0)