Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #892 from alexbruy/deprecated_plugins
Deprecated plugins support for plugin manager
  • Loading branch information
borysiasty committed Sep 13, 2013
2 parents 9ce316d + 6d5df7c commit 300e864
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 326 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -369,6 +369,7 @@
<file>themes/default/pie-chart.png</file>
<file>themes/default/plugin.png</file>
<file>themes/default/pluginExperimental.png</file>
<file>themes/default/pluginDeprecated.png</file>
<file>themes/default/propertyicons/action.svg</file>
<file>themes/default/propertyicons/attributes.png</file>
<file>themes/default/propertyicons/colormap.png</file>
Expand Down
Binary file added images/themes/default/pluginDeprecated.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/pyplugin_installer/installer.py
Expand Up @@ -208,6 +208,7 @@ def exportPluginsToManager(self):
"error" : plugin["error"],
"error_details" : plugin["error_details"],
"experimental" : plugin["experimental"] and "true" or "false",
"deprecated" : plugin["deprecated"] and "true" or "false",
"version_available" : plugin["version_available"],
"zip_repository" : plugin["zip_repository"],
"download_url" : plugin["download_url"],
Expand Down
10 changes: 9 additions & 1 deletion python/pyplugin_installer/installer_data.py
Expand Up @@ -71,6 +71,7 @@
"error" unicode, # NULL | broken | incompatible | dependent
"error_details" unicode, # error description
"experimental" boolean, # true if experimental, false if stable
"deprecated" boolean, # true if deprected, false if actual
"version_available" unicode, # available version
"zip_repository" unicode, # the remote repository id
"download_url" unicode, # url for downloading the plugin
Expand Down Expand Up @@ -403,6 +404,9 @@ def xmlDownloaded(self):
experimental = False
if pluginNodes.item(i).firstChildElement("experimental").text().strip().upper() in ["TRUE","YES"]:
experimental = True
deprecated = False
if pluginNodes.item(i).firstChildElement("deprecated").text().strip().upper() in ["TRUE","YES"]:
deprecated = True
icon = pluginNodes.item(i).firstChildElement("icon").text().strip()
if icon and not icon.startswith("http"):
icon = "http://%s/%s" % ( QUrl(self.mRepositories[reposName]["url"]).host() , icon )
Expand All @@ -427,6 +431,7 @@ def xmlDownloaded(self):
"rating_votes" : pluginNodes.item(i).firstChildElement("rating_votes").text().strip(),
"icon" : icon,
"experimental" : experimental,
"deprecated" : deprecated,
"filename" : fileName,
"installed" : False,
"available" : True,
Expand Down Expand Up @@ -645,6 +650,7 @@ def pluginMetadata(fct):
"library" : path,
"pythonic" : True,
"experimental" : pluginMetadata("experimental").strip().upper() in ["TRUE","YES"],
"deprecated" : pluginMetadata("deprecated").strip().upper() in ["TRUE","YES"],
"version_available" : "",
"zip_repository" : "",
"download_url" : path, # warning: local path as url!
Expand Down Expand Up @@ -707,12 +713,14 @@ def rebuild(self):
self.mPlugins[i] = self.localCache[i].copy()
settings = QSettings()
allowExperimental = settings.value(settingsGroup+"/allowExperimental", False, type=bool)
allowDeprecated = settings.value(settingsGroup+"/allowDeprecated", False, type=bool)
for i in self.repoCache.values():
for j in i:
plugin=j.copy() # do not update repoCache elements!
key = plugin["id"]
# check if the plugin is allowed and if there isn't any better one added already.
if (allowExperimental or not plugin["experimental"]) \
and (allowDeprecated or not plugin["deprecated"]) \
and not (self.mPlugins.has_key(key) and self.mPlugins[key]["version_available"] and compareVersions(self.mPlugins[key]["version_available"], plugin["version_available"]) < 2):
# The mPlugins dict contains now locally installed plugins.
# Now, add the available one if not present yet or update it if present already.
Expand All @@ -729,7 +737,7 @@ def rebuild(self):
self.mPlugins[key][attrib] = plugin[attrib]
# other remote metadata is preffered:
for attrib in ["name", "description", "about", "category", "tags", "changelog", "author_name", "author_email", "homepage",
"tracker", "code_repository", "experimental", "version_available", "zip_repository",
"tracker", "code_repository", "experimental", "deprecated", "version_available", "zip_repository",
"download_url", "filename", "downloads", "average_vote", "rating_votes"]:
if ( not attrib in translatableAttributes ) or ( attrib == "name" ): # include name!
if plugin[attrib]:
Expand Down
23 changes: 23 additions & 0 deletions src/app/pluginmanager/qgspluginmanager.cpp
Expand Up @@ -187,6 +187,12 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils* pythonUtils )
ckbExperimental->setChecked( true );
}

if ( settings.value( settingsGroup + "/allowDeprecated", false ).toBool() )
{
ckbDeprecated->setChecked( true );
}


int interval = settings.value( settingsGroup + "/checkOnStartInterval", "" ).toInt( );
int indx = mCheckingOnStartIntervals.indexOf( interval ); // if none found, just use -1 index.
comboInterval->setCurrentIndex( indx );
Expand Down Expand Up @@ -659,6 +665,14 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
" </td></tr>"
"</table>" ).arg( tr( "This plugin is experimental" ) );
};
if ( metadata->value( "deprecated" ) == "true" )
{
html += QString( "<table bgcolor=\"#EEBBCC\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">"
" <tr><td width=\"100%\" style=\"color:#660000\">"
" <img src=\":/images/themes/default/pluginDeprecated.png\" width=\"32\"><b>%1</b>"
" </td></tr>"
"</table>" ).arg( tr( "This plugin is deprecated" ) );
};
// if ( metadata->value( "status" ) == t.b.d. )
// {
// html += QString( "<table bgcolor=\"#CCCCFF\" cellspacing=\"2\" cellpadding=\"6\" width=\"100%\">"
Expand Down Expand Up @@ -1228,6 +1242,15 @@ void QgsPluginManager::on_ckbExperimental_toggled( bool state )
QgsPythonRunner::run( "pyplugin_installer.instance().exportPluginsToManager()" );
}

void QgsPluginManager::on_ckbDeprecated_toggled( bool state )
{
QString settingsGroup;
QgsPythonRunner::eval( "pyplugin_installer.instance().exportSettingsGroup()", settingsGroup );
QSettings settings;
settings.setValue( settingsGroup + "/allowDeprecated", QVariant( state ) );
QgsPythonRunner::run( "pyplugin_installer.installer_data.plugins.rebuild()" );
QgsPythonRunner::run( "pyplugin_installer.instance().exportPluginsToManager()" );
}


// PRIVATE METHODS ///////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions src/app/pluginmanager/qgspluginmanager.h
Expand Up @@ -153,6 +153,9 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
//! Reload plugin metadata registry after allowing/disallowing experimental plugins
void on_ckbExperimental_toggled( bool state );

//! Reload plugin metadata registry after allowing/disallowing deprecated plugins
void on_ckbDeprecated_toggled( bool state );

//! Open help browser
void on_buttonBox_helpRequested( ) { QgsContextHelp::run( metaObject()->className() ); }

Expand Down

0 comments on commit 300e864

Please sign in to comment.