2 changes: 1 addition & 1 deletion python/gui/qgspluginmanagerinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class QgsPluginManagerInterface : QObject
virtual void reloadModel() = 0;

//! return given plugin metadata
virtual QMap<QString, QString> * pluginMetadata( QString key ) = 0;
virtual const QMap<QString, QString> * pluginMetadata( QString key ) const = 0;

//! clear the repository listWidget
virtual void clearRepositoryList() = 0;
Expand Down
4 changes: 2 additions & 2 deletions python/pyplugin_installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def checkingDone(self):
tabIndex = 2 # tab 2 contains upgradeable plugins
# finally set the notify label
if status:
self.statusLabel.setText(u' <a href="#%d">%s</a> ' % (tabIndex,status) )
self.statusLabel.setText(u' <a href="%d">%s</a> ' % (tabIndex,status) )
else:
iface.mainWindow().statusBar().removeWidget(self.statusLabel)
self.statusLabel = None
Expand Down Expand Up @@ -256,7 +256,7 @@ def showPluginManagerWhenReady(self, * params):
if len( params ) == 1:
indx = unicode(params[0])
if indx.isdigit() and int(indx) > -1 and int(indx) < 7:
tabIndex = indx
tabIndex = int(indx)
iface.pluginManagerInterface().showPluginManager( tabIndex )


Expand Down
3 changes: 2 additions & 1 deletion python/pyplugin_installer/installer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ def rebuild(self):
settings = QSettings()
allowExperimental = settings.value(settingsGroup+"/allowExperimental", False, type=bool)
for i in self.repoCache.values():
for plugin in i:
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"]) \
Expand Down
2 changes: 1 addition & 1 deletion src/app/pluginmanager/qgsapppluginmanagerinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void QgsAppPluginManagerInterface::reloadModel()


//! return given plugin metadata
QMap<QString, QString> * QgsAppPluginManagerInterface::pluginMetadata( QString key )
const QMap<QString, QString> * QgsAppPluginManagerInterface::pluginMetadata( QString key ) const
{
return mPluginManager->pluginMetadata( key );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pluginmanager/qgsapppluginmanagerinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class QgsAppPluginManagerInterface : public QgsPluginManagerInterface
void reloadModel();

//! return given plugin metadata
QMap<QString, QString> * pluginMetadata( QString key );
const QMap<QString, QString> * pluginMetadata( QString key ) const;

//! clear the repository listWidget
void clearRepositoryList();
Expand Down
47 changes: 37 additions & 10 deletions src/app/pluginmanager/qgspluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils* pythonUtils )

void QgsPluginManager::loadPlugin( QString id )
{
QMap<QString, QString>* plugin = pluginMetadata( id );
const QMap<QString, QString>* plugin = pluginMetadata( id );

if ( ! plugin )
{
Expand Down Expand Up @@ -219,7 +219,7 @@ void QgsPluginManager::loadPlugin( QString id )

void QgsPluginManager::unloadPlugin( QString id )
{
QMap<QString, QString>* plugin = pluginMetadata( id );
const QMap<QString, QString>* plugin = pluginMetadata( id );

if ( ! plugin )
{
Expand Down Expand Up @@ -509,9 +509,9 @@ void QgsPluginManager::reloadModelData()
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
// TODO: implement better sort method instead of these dummy -Z statuses
mModelPlugins->appendRow( createSpacerItem( tr( "Reinstallable", "category: plugins that are installed and available" ) , "installedZ" ) );
if ( hasUpgradeablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Upgradeable", "category: plugins that are installed and there is a newer version available" ), "upgradeableZ") );
mModelPlugins->appendRow( createSpacerItem( tr( "Only locally available", "category: plugins that are only locally available" ), "orphanZ" ) );
if ( hasReinstallablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Reinstallable", "category: plugins that are installed and available" ) , "installedZ" ) );
if ( hasUpgradeablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Upgradeable", "category: plugins that are installed and there is a newer version available" ), "upgradeableZ") );
if ( hasNewerPlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Downgradeable", "category: plugins that are installed and there is an OLDER version available" ), "newerZ" ) );
}

Expand Down Expand Up @@ -547,7 +547,7 @@ void QgsPluginManager::pluginItemChanged( QStandardItem * item )

void QgsPluginManager::showPluginDetails( QStandardItem * item )
{
QMap<QString, QString> * metadata = pluginMetadata( item->data( PLUGIN_BASE_NAME_ROLE ).toString() );
const QMap<QString, QString> * metadata = pluginMetadata( item->data( PLUGIN_BASE_NAME_ROLE ).toString() );

if ( ! metadata ) return;

Expand Down Expand Up @@ -708,10 +708,12 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )

tbDetails->setHtml( html );

// Set buttonInstall text
// Set buttonInstall text (and sometimes focus)
buttonInstall->setDefault( false );
if ( metadata->value( "status" ) == "upgradeable" )
{
buttonInstall->setText( tr( "Upgrade plugin" ) );
buttonInstall->setDefault( true );
}
else if ( metadata->value( "status" ) == "newer" )
{
Expand Down Expand Up @@ -767,9 +769,9 @@ void QgsPluginManager::addPluginMetadata( QString key, QMap<QString, QString> m



QMap<QString, QString>* QgsPluginManager::pluginMetadata( QString key )
const QMap<QString, QString> * QgsPluginManager::pluginMetadata( QString key ) const
{
QMap<QString, QMap<QString, QString> >::iterator it = mPlugins.find( key );
QMap<QString, QMap<QString, QString> >::const_iterator it = mPlugins.find( key );
if ( it != mPlugins.end() )
{
return &it.value();
Expand Down Expand Up @@ -797,9 +799,10 @@ void QgsPluginManager::clearRepositoryList()
//! Add repository to the repository listWidget
void QgsPluginManager::addToRepositoryList( QMap<QString, QString> repository )
{
// If the item is second on the tree, add a context menu
// If it's the second item on the tree, change the button text to plural form and add the filter context menu
if ( buttonRefreshRepos->isEnabled() && treeRepositories->actions().count() < 1 )
{
buttonRefreshRepos->setText( tr("Reload all repositories") );
QAction* actionEnableThisRepositoryOnly = new QAction( tr( "Only show plugins from selected repository" ), treeRepositories );
treeRepositories->addAction( actionEnableThisRepositoryOnly );
connect( actionEnableThisRepositoryOnly, SIGNAL( triggered() ), this, SLOT( setRepositoryFilter() ) );
Expand Down Expand Up @@ -943,6 +946,10 @@ void QgsPluginManager::setCurrentTab( int idx )
}
tbDetails->setHtml( welcomeHTML );
}

// disable buttons
buttonInstall->setEnabled( false );
buttonUninstall->setEnabled( false );
}


Expand Down Expand Up @@ -1174,7 +1181,7 @@ void QgsPluginManager::on_ckbExperimental_toggled( bool state )

bool QgsPluginManager::isPluginLoaded( QString key )
{
QMap<QString, QString>* plugin = pluginMetadata( key );
const QMap<QString, QString>* plugin = pluginMetadata( key );
if ( plugin->isEmpty() )
{
// No such plugin in the metadata registry
Expand All @@ -1199,6 +1206,7 @@ bool QgsPluginManager::isPluginLoaded( QString key )
}



bool QgsPluginManager::hasAvailablePlugins( )
{
for ( QMap<QString, QMap<QString, QString> >::iterator it = mPlugins.begin();
Expand All @@ -1215,6 +1223,25 @@ bool QgsPluginManager::hasAvailablePlugins( )
}



bool QgsPluginManager::hasReinstallablePlugins( )
{
for ( QMap<QString, QMap<QString, QString> >::iterator it = mPlugins.begin();
it != mPlugins.end();
it++ )
{
// plugins marked as "installed" are available for download (otherwise they are marked "orphans")
if ( it->value( "status" ) == "installed" )
{
return true;
}
}

return false;
}



bool QgsPluginManager::hasUpgradeablePlugins( )
{
for ( QMap<QString, QMap<QString, QString> >::iterator it = mPlugins.begin();
Expand Down
5 changes: 4 additions & 1 deletion src/app/pluginmanager/qgspluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
void addPluginMetadata( QString key, QMap<QString, QString> metadata );

//! Return metadata of given plugin
QMap<QString, QString> * pluginMetadata( QString key );
const QMap<QString, QString> * pluginMetadata( QString key ) const;

//! Select one of the vertical tabs programatically
void selectTabItem( int idx );
Expand Down Expand Up @@ -169,6 +169,9 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag
//! Return true if there are plugins available for download in the metadata registry
bool hasAvailablePlugins( );

//! Return true if there are installed plugins also available for download in the metadata registry
bool hasReinstallablePlugins( );

//! Return true if there are upgradeable plugins in metadata the registry
bool hasUpgradeablePlugins( );

Expand Down
10 changes: 5 additions & 5 deletions src/app/qgspluginregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void QgsPluginRegistry::setPythonUtils( QgsPythonUtils* pythonUtils )
mPythonUtils = pythonUtils;
}

bool QgsPluginRegistry::isLoaded( QString key )
bool QgsPluginRegistry::isLoaded( QString key ) const
{
QMap<QString, QgsPluginMetadata>::iterator it = mPlugins.find( key );
QMap<QString, QgsPluginMetadata>::const_iterator it = mPlugins.find( key );
if ( it != mPlugins.end() ) // found a c++ plugin?
return true;

Expand Down Expand Up @@ -107,7 +107,7 @@ QgisPlugin *QgsPluginRegistry::plugin( QString key )
return it->plugin();
}

bool QgsPluginRegistry::isPythonPlugin( QString key )
bool QgsPluginRegistry::isPythonPlugin( QString key ) const
{
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
Expand Down Expand Up @@ -184,7 +184,7 @@ void QgsPluginRegistry::unloadAll()
}


bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion )
bool QgsPluginRegistry::checkQgisVersion( QString minVersion, QString maxVersion ) const
{
// Parse qgisMinVersion. Must be in form x.y.z or just x.y
QStringList minVersionParts = minVersion.split( '.' );
Expand Down Expand Up @@ -593,7 +593,7 @@ bool QgsPluginRegistry::checkPythonPlugin( QString packageName )
return true;
}

bool QgsPluginRegistry::isPythonPluginCompatible( QString packageName )
bool QgsPluginRegistry::isPythonPluginCompatible( QString packageName ) const
{
QString minVersion = mPythonUtils->getPluginMetadata( packageName, "qgisMinimumVersion" );
// try to read qgisMaximumVersion. Note checkQgisVersion can cope with "__error__" value.
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgspluginregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class QgsPluginRegistry
void setQgisInterface( QgisInterface* iface );

//! Check whether this module is loaded
bool isLoaded( QString key );
bool isLoaded( QString key ) const;

//! Retrieve library of the plugin
QString library( QString key );
Expand All @@ -55,7 +55,7 @@ class QgsPluginRegistry
QgisPlugin * plugin( QString key );

//! Return whether the plugin is pythonic
bool isPythonPlugin( QString key );
bool isPythonPlugin( QString key ) const;

//! Add a plugin to the map of loaded plugins
void addPlugin( QString key, QgsPluginMetadata metadata );
Expand Down Expand Up @@ -88,7 +88,7 @@ class QgsPluginRegistry
void restoreSessionPlugins( QString thePluginDirString );

//! Check whether plugin is compatible with current version of QGIS
bool isPythonPluginCompatible( QString packageName );
bool isPythonPluginCompatible( QString packageName ) const;

//! Returns metadata of all loaded plugins
QList<QgsPluginMetadata*> pluginData();
Expand All @@ -104,7 +104,7 @@ class QgsPluginRegistry

//! Check current QGIS version against requested minimal and optionally maximal QGIS version
//! if maxVersion not specified, the default value is assumed: floor(minVersion) + 0.99.99
bool checkQgisVersion( QString minVersion, QString maxVersion = "" );
bool checkQgisVersion( QString minVersion, QString maxVersion = "" ) const;

private:
static QgsPluginRegistry* _instance;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgspluginmanagerinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GUI_EXPORT QgsPluginManagerInterface : public QObject
virtual void reloadModel() = 0;

//! return given plugin metadata
virtual QMap<QString, QString> * pluginMetadata( QString key ) = 0;
virtual const QMap<QString, QString> * pluginMetadata( QString key ) const = 0;

//! clear the repository listWidget
virtual void clearRepositoryList() = 0;
Expand Down
25 changes: 14 additions & 11 deletions src/ui/qgspluginmanagerbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>857</width>
<width>812</width>
<height>507</height>
</rect>
</property>
Expand Down Expand Up @@ -124,7 +124,7 @@
<string>Get more</string>
</property>
<property name="toolTip">
<string>Uninstalled plugins available for download</string>
<string>Not installed plugins available for download</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand All @@ -139,7 +139,7 @@
<string>Upgradeable</string>
</property>
<property name="toolTip">
<string>Installed plugins with newer version available</string>
<string>Installed plugins with more recent version available for download</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand All @@ -154,7 +154,7 @@
<string>New</string>
</property>
<property name="toolTip">
<string>New plugins seens for thw first time</string>
<string>Not installed plugins seen for the first time</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand All @@ -169,7 +169,7 @@
<string>Invalid</string>
</property>
<property name="toolTip">
<string>Broken or uncompatible installed plugins</string>
<string>Broken and incompatible installed plugins</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down Expand Up @@ -398,7 +398,7 @@
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
Expand Down Expand Up @@ -442,8 +442,7 @@
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(244, 244, 244);
padding: 0px</string>
<string notr="true">padding: 0px</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
Expand Down Expand Up @@ -634,7 +633,7 @@ padding: 0px</string>
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; If this function is enabled, QGIS will inform you whenever a new plugin or plugin update is available. Otherwise, fetching repositories will be performed during opening the Plugin Manager window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; If this function is enabled, QGIS will inform you whenever a new plugin or plugin update is available. Otherwise, fetching repositories will be performed during opening of the Plugin Manager window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -790,8 +789,12 @@ p, li { white-space: pre-wrap; }
</property>
<item>
<widget class="QPushButton" name="buttonRefreshRepos">
<property name="toolTip">
<string>Reload repository contents
(useful when you uploaded a plugin there)</string>
</property>
<property name="text">
<string>Reload all repositories</string>
<string>Reload repository</string>
</property>
</widget>
</item>
Expand All @@ -811,7 +814,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QPushButton" name="buttonAddRep">
<property name="toolTip">
<string>Add a new plugin repository</string>
<string>Configure an additional plugin repository</string>
</property>
<property name="whatsThis">
<string>Add a new plugin repository</string>
Expand Down