Fix bug in plugin manager introduced by recent changes I made that causes it to not remember loaded plugns properly

git-svn-id: http://svn.osgeo.org/qgis/trunk@8792 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2008-07-16 09:56:54 +00:00
parent 82971f40a1
commit e40991ee32

View File

@ -161,8 +161,7 @@ void QgsPluginManager::getPythonPluginDescriptions()
//myData.setIcon(pixmap); //todo use a python logo here //myData.setIcon(pixmap); //todo use a python logo here
myData.setCheckable(true); myData.setCheckable(true);
myData.setRenderAsWidget(false); myData.setRenderAsWidget(false);
QVariant myVariant = qVariantFromValue(myData); myData.setChecked(false); //start off assuming false
mypDetailItem->setData(myVariant,PLUGIN_DATA_ROLE);
// check to see if the plugin is loaded and set the checkbox accordingly // check to see if the plugin is loaded and set the checkbox accordingly
QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance(); QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
@ -177,9 +176,11 @@ void QgsPluginManager::getPythonPluginDescriptions()
if (libName == packageName) if (libName == packageName)
{ {
// set the checkbox // set the checkbox
mypDetailItem->setCheckState(Qt::Checked); myData.setChecked(true);
} }
} }
QVariant myVariant = qVariantFromValue(myData);
mypDetailItem->setData(myVariant,PLUGIN_DATA_ROLE);
// Add item to model // Add item to model
mModelPlugins->appendRow(mypDetailItem); mModelPlugins->appendRow(mypDetailItem);
} }
@ -358,7 +359,9 @@ void QgsPluginManager::unload()
{ {
// FPV - I want to use index. You can do evrething with item. // FPV - I want to use index. You can do evrething with item.
QModelIndex myIndex=mModelPlugins->index(row,0); QModelIndex myIndex=mModelPlugins->index(row,0);
if (mModelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0) QgsDetailedItemData myData =
qVariantValue<QgsDetailedItemData>(mModelPlugins->data(myIndex,PLUGIN_DATA_ROLE));
if (!myData.isChecked())
{ {
// iThe plugin name without version string in its data PLUGIN_LIB [ts] // iThe plugin name without version string in its data PLUGIN_LIB [ts]
myIndex=mModelPlugins->index(row,0); myIndex=mModelPlugins->index(row,0);
@ -402,7 +405,10 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
// FPV - I want to use item here. You can do everything with index if you want. // FPV - I want to use item here. You can do everything with index if you want.
for (int row=0;row < mModelPlugins->rowCount();row++) for (int row=0;row < mModelPlugins->rowCount();row++)
{ {
if (mModelPlugins->item(row,0)->checkState() == Qt::Checked) QgsDetailedItemData myData =
qVariantValue<QgsDetailedItemData>(mModelPlugins->item(row,0)->data(PLUGIN_DATA_ROLE));
if (myData.isChecked())
{ {
QString pluginName = mModelPlugins->item(row,0)->data(PLUGIN_LIBRARY_NAME_ROLE).toString(); QString pluginName = mModelPlugins->item(row,0)->data(PLUGIN_LIBRARY_NAME_ROLE).toString();
bool pythonic = false; bool pythonic = false;